<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- basic styles -->
		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
		<link rel="stylesheet" href="css/jNotify.jquery.css" />  <!-- 提示框插件 -->
		<script src="assets/js/jquery-2.0.3.min.js"></script>
<title>管理中心 | 首页</title>
</head>
<body>
		<%@ include file="/include/ace_top_header.jsp" %>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<%@ include file="/include/ace_left_header.jsp" %>

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">管理中心</a>
							</li>
							<li class="active">控制台</li>
						</ul><!-- .breadcrumb -->

					
					</div>

					<div class="page-content">
						<div class="page-header">
							<h1>
								管理中心
								<small>
									<i class="icon-double-angle-right"></i>
									 控制台
								</small>
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->


<!-- 问卷start -->
                        <div id="timeline-1">
                            <div class="row">
                                <div class="col-xs-12 col-sm-10 col-sm-offset-1">
                                     
                                     
                                     
                                            <div class="timeline-container">  <!-- 关注的动态 -->
												<div class="timeline-label">  <!-- “好友动态”标签 -->
													<span class="label label-primary arrowed-in-right label-lg">
														<b>蓝色领域问卷 </b>
														
													</span>
													
												</div>
														<div class="timeline-items">
													   <div class="timeline-item clearfix">
													   
																<div class="timeline-info at_user_photo">
		<span class="label label-info label-sm nickname">主题</span>
		</div>			   
			<div class="widget-box transparent">
															<div class="widget-header widget-header-small">
																<h5 class="smaller">
																	<span class="grey atdy_date"><input id="questionnaire_theme" class="col-xs-6 col-sm-6" placeholder="问卷主题" type="text"></span>
																	<span class="widget-toolbar no-border">                                                                                                                         
                                                                </span>
																</h5>
															</div>
                                    </div><!-- /widget-body -->										



 
                                                                     
													   
										
                                    
                                    
                                    
                                    <div class="space" id="Blank_line_marker"></div>
                                    
                                    
                                    <!-- 新建题目start -->
<div class="widget-box transparent">
															<div class="widget-body">
																<div class="widget-main">
																	<div class="widget-toolbox clearfix">
																		<div class="pull-left action-buttons">
<button class="btn btn-info new_radio" type="button">
新建单选题目
</button>
<button class="btn btn-info new_check" type="button">
新建复选题目
</button>
<button class="btn btn-info save_questionnaire" type="button">
<i class="icon-ok bigger-110"></i>
保存问卷
</button>

                                                                        </div>
																	</div>
																</div>
                                        </div><!-- /widget-main -->
                                    </div><!-- /widget-body -->
                                    
                                    <!-- 新建题目end -->
                                    
                            </div><!-- /span -->
                            
															</div>
															
														</div>
													</div>   
                                                              
                                                              
                                                                        
                                                 </div><!-- /.timeline-items -->
											</div><!-- /.timeline-container -->
											<!-- 问卷end -->
											
											
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->

				
			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->



		<!--[if IE]>
<script src="assets/js/jquery-1.10.2.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="assets/js/excanvas.min.js"></script>
		<![endif]-->

		<script src="assets/js/jquery-ui-1.10.3.custom.min.js"></script>
		<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="assets/js/jquery.slimscroll.min.js"></script>
		<script src="assets/js/jquery.easy-pie-chart.min.js"></script>
		<script src="assets/js/jquery.sparkline.min.js"></script>
		<script src="assets/js/flot/jquery.flot.min.js"></script>
		<script src="assets/js/flot/jquery.flot.pie.min.js"></script>
		<script src="assets/js/flot/jquery.flot.resize.min.js"></script>

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>

		<!-- inline scripts related to this page -->
		
		<!-- 单选/复选模版 -->
		<!-- 复选选项模版start -->
		<label class="ckeck_option_template hidden">
<input class="ace ace-checkbox-2" name="form-field-checkbox" type="checkbox">
<span class="lbl"><input class="input-sm marker_option" placeholder="选项类容" type="text"></span>
</label>
		<!-- 复选选项模版end -->
		
		<!-- 单选选项模版start -->
		<div class="radio radio_option_template hidden">
<label>
<input class="ace" name="form-field-radio" type="radio">
<span class="lbl"> <input class="input-sm marker_option" placeholder="选项类容" type="text"></span>
</label>
</div>
		<!-- 单选选项模版end -->
		
		<div class="space hidden"></div><!-- 空格 -->
		<div class="timeline-info at_user_photo hidden">
		<span class="label label-info label-sm nickname">题目</span>
		</div>
		<!-- 复选题开始 -->
		
                                    
                                                       
														
														<div class="widget-box transparent check_template hidden marker_title">
															<div class="widget-header widget-header-small">
																<h5 class="smaller">
																	<span class="grey atdy_date"><input class="col-xs-10 col-sm-5 subject_content" placeholder="题目类容" type="text"></span>
																</h5>
																<span class="widget-toolbar no-border">
                                                                     <a href="javascript:;">
                                                                            <i class="icon-trash red delete bigger-125"></i>
                                                                     </a>                                                                                                                                                                    
                                                                </span>
															</div>

															<div class="widget-body">
																<div class="widget-main">

																	<div class="widget-toolbox clearfix">

																		<div class="pull-left action-buttons">
																		
<div class="checkbox">
<label>
<button class="btn btn-sm btn-default new_ckeck_option" type="button">
新建选项
</button>
</label>
</div>
                                                                        </div>
																	</div>
																</div>
                                        </div><!-- /widget-main -->
                                    </div><!-- /widget-body -->
		<!-- 复选题end -->
		
		<!-- 单选题start -->

														<div class="widget-box transparent radio_template hidden marker_title">
															<div class="widget-header widget-header-small">
																<h5 class="smaller">
																	<span class="grey atdy_date"><input class="col-xs-10 col-sm-5 subject_content" placeholder="题目类容" type="text"></span>
																	<span class="widget-toolbar no-border">
                                                                     <a href="javascript:;">
                                                                            <i class="icon-trash red delete bigger-125"></i>
                                                                     </a>                                                                                                                                                                    
                                                                </span>
																</h5>
															</div>

															<div class="widget-body">
																<div class="widget-main">

																	<div class="widget-toolbox clearfix">

																		<div class="pull-left action-buttons">

<div>
<label>
<button class="btn btn-sm btn-default new_radio_option" type="button">
新建选项
</button>
</label>
</div>                                                   
                                                                        </div>
																	</div>
																</div>
                                        </div><!-- /widget-main -->
                                    </div><!-- /widget-body -->
		<!-- 单选题end -->
		<!-- 模版end -->
		<script src="js/jNotify.jquery.js"></script>  <!-- 提示框插件 -->
		<script>
		$(function(){
			
			var $save_questionnaire = $("button.save_questionnaire");
			var $new_radio = $("button.new_radio");    //单选题目按钮
			var $new_radio_option = $("button.new_radio_option");    //单选选项按钮
			var $new_check = $("button.new_check");    //复选题目按钮
			var $new_ckeck_option = $("button.new_ckeck_option");   //复选选项按钮
			
			var $radio_option_template = $("div[class='radio radio_option_template hidden']");
			var $ckeck_option_template = $("label[class='ckeck_option_template hidden']");   //复选选项模版
			
			var $Blank_line_marker = $("#Blank_line_marker");    //空行标记
			var $space = $("div[class='space hidden']"); //空格
			var $the_title = $("div[class='timeline-info at_user_photo hidden']");  //题目
			  
			var $check_template = $("div[class='widget-box transparent check_template hidden marker_title']");    //复选模版
			var $radio_template = $("div[class='widget-box transparent radio_template hidden marker_title']");  //单选模版
			   
			
			$new_ckeck_option.click(function(){
				var cot = $ckeck_option_template.clone(true);
				cot.removeClass("hidden");
				cot.insertBefore($(this));
			});
			
			
			$new_radio_option.click(function(){
				var rot = $radio_option_template.clone(true);
				rot.removeClass("hidden");
				rot.insertBefore($(this).parent());
			});
			
			
			$new_check.click(function(){
				var ct1 = $space.clone(true);
				var ct2 = $the_title.clone(true);
				var ct3 = $check_template.clone(true);
				
				ct1.removeClass("hidden");
				ct2.removeClass("hidden");
				ct3.removeClass("hidden");
				
				ct1.insertBefore($Blank_line_marker);
				ct2.insertBefore($Blank_line_marker);
				ct3.insertBefore($Blank_line_marker);
			});
			
			$new_radio.click(function(){
				var rt1 = $space.clone(true);
				var rt2 = $the_title.clone(true);
				var rt3 = $radio_template.clone(true);
				
				rt1.removeClass("hidden");
				rt2.removeClass("hidden");
				rt3.removeClass("hidden");
				
				rt1.insertBefore($Blank_line_marker);
				rt2.insertBefore($Blank_line_marker);
				rt3.insertBefore($Blank_line_marker);
			});
			
			
			$save_questionnaire.click(function(){
				var questionnaire_theme = $("#questionnaire_theme").val();
				//var questionnaire_content = new Array();
				var questionnaire_content = [];
				
				$("div.marker_title").not(".hidden").each(function(i,the){
					var json = {};
					
					if($(this).hasClass("radio_template")){
						json.title_type = 0;    //单选
					}else if($(this).hasClass("check_template")){
						json.title_type = 1;      //复选
					}
					json.subject_content = $(this).find("input.subject_content").val();   //这个地方还是要用$(this),不能用$the
					
					var option = [];    //选项类容
					$(this).find("input.marker_option").each(function(j,the){
						var op = {};
						op.option_content = $(this).val();
						op.number = 0;
						option[j] = op;
					});
					json.option = option;
					
					questionnaire_content[i] = json;
				});

				$.post("Questionnaire_deal",{questionnaire_theme:questionnaire_theme,questionnaire_content:JSON.stringify(questionnaire_content)},function(data,status){
					if(data.result == true){
						jSuccess("问卷已发布",{HorizontalPosition : "center",VerticalPosition : "center",ShowOverlay : false});
					}else{
						jError("问卷发布失败",{HorizontalPosition : "center",VerticalPosition : "center",ShowOverlay : false});
					}
				},"json");
				
			});
	
		});
		
		</script>
		
		
</body>
</html>